from typing import List


class Solution:
    def addSpaces(self, s: str, spaces: List[int]) -> str:
        result = ""
        for i in range(len(spaces)):
            # print(s[spaces[i] - 1:spaces[i]])
            # print(s[1:4])
            if i == 0:
                result += s[0:spaces[i]]
            else:
                result += s[spaces[i - 1]:spaces[i]]
            result += " "
        result += s[spaces[len(spaces)-1]:]
        return result


if __name__ == '__main__':
    a = Solution()
    print(a.addSpaces("LeetcodeHelpsMeLearn", [8,13,15]))
